package org.sell.core.task01;

import org.sell.core.domain.Task1DTO;
import org.sell.excepiton.SellException;

import tw.com.sell.db.dao.BillDAO;
import tw.com.sell.db.domain.Bill;
import tw.com.sell.db.util.DBHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TaskServiceImpl implements TaskService {

	private static final String TAG = TaskServiceImpl.class.getSimpleName();

	public void addBill(Task1DTO dto, Context ct) throws SellException {

		final DBHelper help = new DBHelper(ct);
		final SQLiteDatabase conn = help.getWritableDatabase();

		try {
			conn.beginTransaction();

			final BillDAO<String> billDAO = new BillDAO<String>(conn);

			Bill bill = new Bill();
			billDAO.addBill(bill);
			conn.endTransaction();
		} catch (Exception e) {
			conn.inTransaction();
			Log.e(TAG, "e=" + e);
			throw new SellException("E-001", "帳單新增失敗");
		} finally {
			conn.close();
		}

		// TODO Auto-generated method stub

	}
}
